//
//  GQProfileFeedBack.m
//  GuQu
//
//  Created by HELIUM STAR on 15/5/26.
//  Copyright (c) 2015年 HELIUM STAR. All rights reserved.
//

#import "GQProfileFeedBack.h"

@interface GQProfileFeedBack () <UITextViewDelegate>

@property (strong, nonatomic) UITextField *textField;
@property (strong, nonatomic) UITextView *textView;

@end

@implementation GQProfileFeedBack

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageWithOriginalName:@"distribute_back"] style:UIBarButtonItemStylePlain target:self action:@selector(backToPre)];
    
    UIButton *rightItem = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 35, 20)];
    [rightItem setTitle:@"发送" forState:UIControlStateNormal];
    rightItem.titleLabel.font = [UIFont systemFontOfSize:16];
    [rightItem setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [rightItem addTarget:self action:@selector(sendMessageBtnClick) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightItem];
    self.title = @"意见反馈";
    self.view.backgroundColor = [UIColor lightGrayColor];
    UITextView *textView = [[UITextView alloc] init];
    self.automaticallyAdjustsScrollViewInsets = NO;
    textView.frame = CGRectMake(0, kNavigatationBarHeight, self.view.width, 180);
    textView.font = [UIFont systemFontOfSize:14];
    textView.delegate = self;
    UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(5, 8, self.view.width, 20)];
    textField.enabled = NO;
    textField.font = [UIFont systemFontOfSize:14];
    textField.placeholder = @"描述一下你的问题";
    //label.backgroundColor = [UIColor cyanColor];
    [textView addSubview:textField];
    self.textField = textField;
    self.textView = textView;
    [self.view addSubview:textView];
}

- (void)sendMessageBtnClick
{
    NSLog(@"555");
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    self.textView.returnKeyType = UIReturnKeySend;
    [self.textView becomeFirstResponder];
    
}

- (void)backToPre
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)textViewDidChange:(UITextView *)textView
{
    NSLog(@"%ld", textView.text.length);
    if (textView.text.length > 0) {
        NSLog(@"555");
        self.textField.placeholder = @"";
    }else if (textView.text.length == 0){
        self.textField.placeholder = @"描述一下你的问题";
    }
    if (textView.text.length > 300) {
        textView.text = [textView.text substringToIndex:300];
    }
}

@end
